# Cmake minimum version requirements
cmake_minimum_required(VERSION 3.21...3.31 FATAL_ERROR)

# Set cmake scripts folder path so that cmake could find the scripts, later, you can use include() command
set(DEVKITS_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The path to the cmake scripts folder")
list(APPEND CMAKE_MODULE_PATH ${DEVKITS_CMAKE_DIR})

# Project name and version, replace it with your own project version
project(AppExample VERSION "1.0.0" LANGUAGES CXX)
message(STATUS "Configuring project: ${PROJECT_NAME} v${PROJECT_VERSION}")

set(EXECUTABLE_NAME "${PROJECT_NAME}-v${PROJECT_VERSION}")

# Required cpp library version
set(CMAKE_CXX_STANDARD 17)

# set default build type as Debug
if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug)
endif ()

# set default binary and library output path
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/output/${CMAKE_BUILD_TYPE}/${EXECUTABLE_NAME})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/output/${CMAKE_BUILD_TYPE}/${EXECUTABLE_NAME})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/output/${CMAKE_BUILD_TYPE}/${EXECUTABLE_NAME})

# Generate build information
include(BuildInfo)
create_build_info()

# Load options
include(Options)

# Third part libraries
include(ProjectBoost)
include(ProjectQt6)

# Print info
configure_project()

# Add project path to include path
include_directories(${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

# App components
add_subdirectory(libapp)
add_subdirectory(libdevcore)
add_subdirectory(libinitializer)
if (QML_GUI)
    add_subdirectory(libguiqml)
    add_definitions(-DQML_GUI)
    message(STATUS "Building with QML GUI support")
else ()
    add_subdirectory(libgui)
    message(STATUS "Building with QWidget GUI support")
endif ()
add_subdirectory(main)

# Unit test settings
if (TESTS)
    enable_testing()
    add_subdirectory(test)
endif ()
